package com.kx.ssm.mapper;


import com.kx.ssm.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {
    @Select("SELECT * FROM users")
    List<User> findAllUsers();

    @Select("SELECT * FROM users WHERE id = #{id}")
    User getUserById(Long id);

    @Select("select * from users where username=#{username}")
    User findUserByUserName(String username);

    @Insert("INSERT INTO users (username,password,passwordSalt,age,address,birthday,picurl) VALUES(#{username},#{password},#{passwordSalt},#{age},#{address},#{birthday},#{picurl})")
    void addUser(User user);

    int updateUser(User user);

    @Delete("delete from users where id=#{id}")
    int deleteUser(Long id);

}
